package com.example.anql.controller;

import com.example.anql.common.ReturnObject;
import com.example.anql.entity.ShopMassage;
import com.example.anql.service.ShopMassageService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (ShopMassage)表控制层
 *
 * @author makejava
 * @since 2022-12-12 10:39:59
 */
@RestController
@RequestMapping("/shopMassage")
public class ShopMassageController {
    /**
     * 服务对象
     */
    @Resource
    private ShopMassageService shopMassageService;

    /**
     * 分页查询
     *
     * @param shopMassage 筛选条件
     * @return 查询结果
     */
    @PostMapping("/queryByPage")
    public ReturnObject queryByPage(@RequestBody ShopMassage shopMassage ) {

        return shopMassageService.queryByPage(shopMassage);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @PostMapping("/queryById")
    public ResponseEntity<ShopMassage> queryById(@RequestBody  ShopMassage shopMassage ) {
        return ResponseEntity.ok(this.shopMassageService.queryById(shopMassage.getId()));
    }

    /**
     * 新增数据
     *
     * @param shopMassage 实体
     * @return 新增结果
     */
    @PostMapping("/add")
    public ResponseEntity<ShopMassage> add(@RequestBody  ShopMassage shopMassage) {
        return ResponseEntity.ok(this.shopMassageService.insert(shopMassage));
    }

    /**
     * 编辑数据
     *
     * @param shopMassage 实体
     * @return 编辑结果
     */
    @PostMapping("/edit")
    public ResponseEntity<ShopMassage> edit(@RequestBody ShopMassage shopMassage) {
        return ResponseEntity.ok(this.shopMassageService.update(shopMassage));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @PostMapping("/deleteById")
    public ResponseEntity<Boolean> deleteById(@RequestBody  ShopMassage shopMassage) {
        return ResponseEntity.ok(this.shopMassageService.deleteById(shopMassage.getId()));
    }

}

